// 代理单例模式
function singleton(className) {
  let ins;
  return new Proxy(className, {
    construct(target, args) {
      if (!ins) {
        ins = new className(target, ...args);
      } else {
        console.error(className.name + "单例模式已经存在");
      }
      return ins;
    },
  });
}

export default singleton;
